﻿using Anke.SHManage.BLL;
using Anke.SHManage.MSSQLDAL.TJDAL;
using Microsoft.Reporting.WebForms;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Anke.SHManage.Web.Reports
{
    public partial class NothingModeWebForm : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Data_Binding();
            }
        }
        private void Data_Binding()
        {
            string ReportMonth = Request.QueryString["ReportTime"];
            string MaterialType = Request.QueryString["MaterialType"];
            string reportMonth = ReportMonth.ToString();
            string materialType = MaterialType.ToString();
            string reportName = "";
            if (materialType == "MaterialType-9998")
            { reportName = "药品器械收发存清单"; }
            else if (materialType == "MaterialType-9999")
            { reportName = "汽车配件收发存清单"; }

            List<string> mTypeList = UserOperateContext.Current.getMaterialTypeLists(MaterialType); //add2021-10-15
            MaterialType = string.Join("','", mTypeList.ToArray());

            this.ReportViewer1.LocalReport.DataSources.Clear();
            this.ReportViewer1.LocalReport.ReportPath = Server.MapPath(@"~/Reports/TJ_IMBalanceDetial.rdlc");
            Microsoft.Reporting.WebForms.ReportParameter name = new Microsoft.Reporting.WebForms.ReportParameter("ReportName", reportName);
            Microsoft.Reporting.WebForms.ReportParameter month = new Microsoft.Reporting.WebForms.ReportParameter("ReportMonth", reportMonth);
            this.ReportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { name, month });
            TJDAL dal = new TJDAL();
            DataTable dt = dal.Get_TJ_BalanceDetial(ReportMonth, MaterialType);
            this.ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSetForTJ_BalanceDetial", dt));
            this.ReportViewer1.LocalReport.Refresh();
        }
    }
}